package com.dxwan.observables.filtering;

import io.reactivex.Observable;

import java.util.concurrent.TimeUnit;

public class App {
    public static void main(String[] args) {
        System.out.println("first:---------------------------");
        Observable
                .just(1,2,3,4,5)
                .first(0)
                .subscribe( System.out::println);

        System.out.println("last:---------------------------");
        Observable
                .just(1,2,3,4,5)
                .last(0)
                .subscribe( System.out::println);

        System.out.println("distinct:---------------------------");
        Observable
                .just(1,2,3,2,5)
                .distinct()
                .subscribe( System.out::println);

        System.out.println("elementAt:---------------------------");
        Observable
                .just(1,2,3,2,5)
                .elementAt(2)
                .subscribe( System.out::println);

        System.out.println("filter:---------------------------");
        Observable
                .just(1,2,3,2,5)
                .filter( x->x%2 != 0)
                .subscribe( System.out::println);

        System.out.println("ignoreElements:---------------------------");
        Observable
                .just(1,2,3,2,5)
                .ignoreElements()
                .subscribe( ()-> System.out.println("finished."));

        //je ne sais pas
        System.out.println("sample:---------------------------");
        Observable
                .just(1,2,3,2,5)
                .sample(1, TimeUnit.SECONDS)
                .subscribe( System.out::println);





    }
}
